package com.hhxy.consumer;

import com.hhxy.config.DelayedQueueConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.security.auth.login.Configuration;
import java.util.Date;

/**
 * @author ghp
 * @date 2023/2/26
 * @title
 * @description 消费来自延迟队列的延迟消息（基于延迟插件实现延迟队列）
 */
@Slf4j
@Component
public class DeadQueueConsumer {

    @RabbitListener(queues = DelayedQueueConfig.DELAYED_QUEUE)
    public void receiveDelayedQueue(Message message){
        String msg = new String(message.getBody());
        log.info("当前时间:{}, 收到死信队列的消息:{}", new Date(), msg);
    }
}
